package com.yum.lang;

import com.yum.Iterator.Arrays.YArrays;

import java.io.Serializable;
import java.util.Arrays;

/**
 * Created on 2023/5/25
 *
 * @Time 19:43
 * @Program YunMap
 * @Author YoHaNe/XiaoShuai
 */
public class YString implements Serializable,Comparable<YString>,YCharSequence {

    private static final long serialVersionUID = -6542051249284262702L;

    private final char[] value;

    private int hash;

    public YString(){
        this.value = new char[0];
    }

    public YString(YString original){
        this.value = original.value;
        this.hash = original.hash;
    }

    public YString(char[] value) {
        this.value = YArrays.copyOf(value,value.length);
    }

    public static String toString(int val){
        return YInteger.toString(val);
    }

    @Override
    public int compareTo(YString o) {
        return 0;
    }

    @Override
    public int len() {
        return value.length;
    }

    @Override
    public char charAt(int index) {
        if(index < 0 || index > value.length)
            throw new StringIndexOutOfBoundsException(index);
        return value[index];
    }
}
